package com.cloud.system.api.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cloud.system.api.entity.SysResources;
import com.cloud.system.api.service.ResourcesService;
import com.cloud.system.common.result.Quokka;

@RestController
@RequestMapping("system/api/resources")
public class ResourcesController {

	@Autowired
	private ResourcesService resourcesService;

	@RequestMapping("/listtree")
	public Quokka listResourcesTree() {
		return new Quokka(true, resourcesService.listResourcesTree());
	}

	@RequestMapping("/listbysys")
	public Quokka listResourcesBySys(long sysId) {
		return new Quokka(true, resourcesService.listResourcesBySysId(sysId));
	}

	@RequestMapping("/delete")
	public Quokka deleteResource(long id) {
		return new Quokka(true, resourcesService.deleteResource(id));
	}

	@RequestMapping("/load")
	public Quokka loadResource(long id) {
		return new Quokka(true, resourcesService.loadResource(id));
	}
	
	@RequestMapping("/showeditdetail")
	public Quokka showEditResourceDetail(long id, long sysId) {
		return new Quokka(true, resourcesService.showEditResourceDetail(id, sysId));
	}

	@RequestMapping("/saveupdate")
	public Quokka saveUpdateResource(@RequestBody(required = true) SysResources resource) {
		return new Quokka(true, resourcesService.saveUpdateResource(resource));
	}
}
